import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'
import OrderView from "@/views/OrderView";
import ProductView from "@/views/ProductView";


import HotelView from "@/views/HotelView";
import SpotView from "@/views/RouteView";
import RouteView from "@/views/RouteView";


Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: HomeView,
    redirect: '/index/product',
    children:[

      {
        path: '/order',
        component: () => import('../views/OrderView.vue'),
      },
      {
        path: '/pay',
        name: 'pay',
        props: true,
        component: () => import('../views/PayView.vue'),
      },
      {
        path: '/invoice',
        component: () => import('../views/InvoiceView.vue'),
      },
      {
        name: 'login',
        path: '/login',
        component:() => import('../views/LoginView.vue'),
      },
      {
        name: 'adminLogin',
        path: '/adminLogin',
        component:() => import('../views/AdminLoginView'),
      },
      {
        path: '/reg',
        component:() => import('../views/RegView.vue'),
      },
      {
        path: '/personal',
        component:() => import('../views/PersonalView.vue'),
        redirect: '/personal/userInfo',
        children:[
          {
            path: '/personal/userInfo',
            component: () => import('../views/personal/UserInfoView.vue')
          },
          {
            path: '/personal/changeInfo',
            component: () => import('../views/personal/ChangeInfoView.vue')
          },
          {
            path: '/personal/password',
            component: () => import('../views/personal/PasswordView.vue')
          },
          {
            path: 'myArticle',
            component: () => import('../views/personal/MyArticleView')
          },
          {
            path: 'myArticleUp',
            component: () => import('../views/personal/MyArticleUpView')
          },
          {
            path: 'myArticleCollect',
            component: () => import('../views/personal/MyArticleCollectView')
          },
          {
            path: 'rejectArticle',
            component: () => import('../views/personal/RejectArticle')
          },

        ]
      },
      {
        path: '/product',
        component: () => import('../views/ProductView'),
        children:[ ]
      },
      {
        path: '/productList',
        component: () => import('../views/ProductList'),

      },
      {
        path: '/hotel',
        component: () => import('../views/HotelView'),
      },
      {
        path: '/route',
        component: () => import('../views/RouteView'),
      },
      {
        path: '/spot',
        component: () => import('../views/SpotView'),
      },

      {
        path: 'detail',
        component: () => import('../views/community/ArticleDetailView.vue')
      },
      {
        path: 'community',
        component: () => import('../views/community/CommunityView.vue'),
        redirect:'/community/all',
        children:[
          {
            path: 'all',
            name:'all',
            component: () => import('../views/community/AllView.vue'),
            beforeEnter(all,search,next){
              all.meta.textSearch = '';
              next();
            }
          },
          {
            path: 'hot',
            component: () => import('../views/community/HotView.vue')
          },
          {
            path: 'recent',
            component: () => import('../views/community/RecentView.vue')
          },
          {
            path: 'search',
            name:'search',
            component: () => import('../views/community/SearchView.vue')
          }
        ]
      },
      {
        path: '/index',
        component: () => import('../views/index/Index.vue'),
        redirect: '/index/product',
        children:[
          {
            path: 'product',
            component: () => import('../views/index/index01/Product.vue'),
          },
          {
            path: 'hot',
            component: () => import('../views/index/index01/SearchIndex.vue'),
          },
        ]
      },
      ]
  },
  {
    name: "articlePost",
    path: '/articlePost',
    component: () => import('../views/community/ArticlePostView.vue')
  },

  {
    path: '/admin',
    component: () => import('../views/admin/AdminIndex.vue'),
    redirect:"/admin/user",
    children: [
      {
        path: 'user',
        component: () => import('../views/admin/User.vue')
      },
      {
        path: 'role',
        component: () => import('../views/admin/Role.vue')
      },
      {
        path: '/admin/product/routeProduct',
        component: () => import('../views/admin/product/RouteProduct.vue'),
      },
      {
        path: '/admin/product/hotelProduct',
        component: () => import('../views/admin/product/HotelProduct.vue'),
      },
      {
        path: '/admin/product/spotProduct',
        component: () => import('../views/admin/product/SpotProduct.vue'),
      },
      {
        path: 'authority',
        component: () => import('../views/admin/Authority.vue')
      },
      {
        path: 'detail',
        component: () => import('../views/community/ArticleDetailView')
      },
      {
        path: 'category',
        component: () => import('../views/admin/Category')
      },
      {
        path: 'blog',
        component: () => import('../views/admin/Blog'),
        redirect:"/admin/blog/checkSuccess",
        children:[
          {
            path: 'checkSuccess',
            component: () => import('../views/admin/article/checkSuccess')
          },
          {
            path: 'unCheck',
            component: () => import('../views/admin/article/unCheck')
          },
          {
            path: 'rejectCheck',
            component: () => import('../views/admin/article/rejectCheck')
          },
        ]
      },
      {
        path: 'order',
        component: () => import('../views/admin/Order')
      },
      {
        path: 'invoice',
        component: () => import('../views/admin/Invoice')
      },

    ]

  },
  {
  path: '/success',
    component: () => import('../views/Success')
  }




]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
